<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags" %>
<%@ page import="com.fengke.csc.config.HostConfig" %>
<%
	HostConfig hostConfig = (HostConfig) request.getSession().getServletContext().getAttribute("hostConfig");
%>
<!DOCTYPE html>
	<!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]-->
	<!--[if IE 7 ]>    <html lang="en" class="no-js ie7"> <![endif]-->
	<!--[if IE 8 ]>    <html lang="en" class="no-js ie8"> <![endif]-->
	<!--[if IE 9 ]>    <html lang="en" class="no-js ie9"> <![endif]-->
	<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"><!--<![endif]-->
	<head>
		<title><%=hostConfig.getWebSiteName() %></title>
		<meta name="keywords" content="<%=hostConfig.getWebSiteName() %>" />
		<meta name="description" content="<%=hostConfig.getWebSiteName() %>" />
		<jsp:include page="../gadget/include_header.jsp"></jsp:include>
	</head>
	<body>
		<!-- 头信息 Start -->
		<jsp:include page="../gadget/main_header.jsp"></jsp:include>
		<!-- 头信息 End -->
		<jsp:include page="../gadget/main_sidebar.jsp"></jsp:include>
		<div class="main-content">
			<div class="breadcrumbs" id="breadcrumbs">
				<script type="text/javascript">
					try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
				</script>

				<ul class="breadcrumb">
					<li>
						<i class="icon-home home-icon"></i>
						<a href="#">首页</a>
					</li>
					<li class="active">订单管理</li>
				</ul><!-- .breadcrumb -->
			</div>
			<div class="page-content">
				<div class="page-header">
					<h1 style="display: inline-block;">
						订单列表
						<small>
							<i class="icon-double-angle-right"></i>
							 查看
						</small>
					</h1>
					<div id="nav-search" style="float: right;">
						<form class="form-search" method="post" action="order/showOrderList.action" id="csc_order_search_form">
							<input type="hidden" value="1" name="pageBean.currentPage" id="csc_order_search_currentPage">
							<label for="csc_order_search_sn">编号：</label><input type="text" name="orderVO.orderModel.sn" id="csc_order_search_sn" value="<s:property value='orderVO.orderModel.sn' />">
							<label for="csc_order_search_productName" style="margin-left: 10px;">产品名称：</label><input type="text" name="orderVO.orderModel.productName" id="csc_order_search_productName" value="<s:property value='orderVO.orderModel.productName' />">
							<label for="csc_order_search_mpaymentStatus" style="margin-left: 10px;">支付状态：</label>
							<select id="csc_order_search_mpaymentStatus" name="orderVO.orderModel.mpaymentStatus">
								<option value="0" <s:if test="orderVO.orderModel.mpaymentStatus == 0">selected="selected"</s:if> ><s:property value="getText('payment.status.unpaid')" /></option>
								<option value="1" <s:if test="orderVO.orderModel.mpaymentStatus == 1">selected="selected"</s:if> ><s:property value="getText('payment.status.partialPayment')" /></option>
								<option value="2" <s:if test="orderVO.orderModel.mpaymentStatus == 2">selected="selected"</s:if> ><s:property value="getText('payment.status.paid')" /></option>
								<option value="3" <s:if test="orderVO.orderModel.mpaymentStatus == 3">selected="selected"</s:if> ><s:property value="getText('payment.status.partialRefunds')" /></option>
								<option value="4" <s:if test="orderVO.orderModel.mpaymentStatus == 4">selected="selected"</s:if> ><s:property value="getText('payment.status.refunded')" /></option>
							</select>
							<button class="btn btn-xs btn-primary" onclick="$('#csc_order_search_currentPage').attr('value', '1');$('#csc_order_search_form').submit();" style="margin-left: 10px;"><i class="icon-search align-top bigger-125"></i>查询</button>
						</form>
					</div><!-- #nav-search -->
				</div><!-- /.page-header -->
				<div class="row">
					<div class="col-xs-12">
						<!-- PAGE CONTENT BEGINS -->

						<div style="margin-bottom: 10px">
							<form id="csc_order_delete_form" action="order/deleteOrder.action" method="post">
								<input type="hidden" id="csc_order_deletedOrderIds" name="value.deletedOrderIds" value="" />
							</form>
							<form id="csc_order_detail_form" action="order/showOrderDetail.action" method="post" >
								<input type="hidden" id="csc_order_detail_orderId" name="orderVO.orderModel.id" value="" />
							</form>
							<button onclick="deleteOrder();" class="btn btn-grey"><i class="icon-trash icon-1.5x"></i>删除</button>
						</div>
						
						<jsp:include page="../gadget/include_pageMessage.jsp"></jsp:include>
						
						<div class="table-responsive dataTables_wrapper">
							<table id="order_list_table" class="table table-striped table-bordered table-hover dataTable">
								<thead>
									<tr>
										<th class="center">
											<label>
												<input type="checkbox" class="ace" />
												<span class="lbl"></span>
											</label>
										</th>
										<th>编号</th>
										<th>订单金额</th>
										<th style="width: 350px;">产品名称</th>
										<th>会员</th>
										<th>支付状态</th>
										<th>
											<i class="icon-time bigger-110 hidden-480"></i>
											创建日期
										</th>
										<th>操作</th>
									</tr>
								</thead>
								<tbody>
									<s:if test="orderVOList != null && orderVOList.size > 0">
										<s:iterator value="orderVOList" var="order" status="countIdx">
											<tr>
												<td class="center">
													<label>
														<input type="checkbox" class="ace" lang="<s:property value='#order.orderModel.id'/>" />
														<span class="lbl"></span>
													</label>
												</td>
												<td><s:property value='#order.orderModel.sn'/></td>
												<td>
													<s:text name="format.number">
														<s:param value="#order.amount"/>
													</s:text>
												</td>
												<td><s:property value='#order.orderModel.productName'/></td>
												<td><s:property value='#order.orderModel.member.username'/></td>
												<td><s:property value="getText('payment.status.' + #order.orderModel.paymentStatus)" /></td>
												<td><s:date name='#order.orderModel.createDate' format="yyyy-MM-dd"/></td>
												<td>
<%-- 													<button onclick="preupdateorder('<s:property value='#order.orderModel.id'/>');" class="btn btn-xs btn-primary"> --%>
<!-- 														<i class='icon-edit'></i> -->
<!-- 														编辑 -->
<!-- 													</button> -->
													<button onclick="showOrderDetail('<s:property value='#order.orderModel.id'/>');" class="btn btn-xs btn-primary">
														<i class='icon-info-sign'></i>
														查看
													</button>
												</td>
											</tr>
										</s:iterator>
									</s:if>
									<s:else>
										<tr>
											<td colspan="8" style="text-align: center">暂无数据</td>
										</tr>
									</s:else>
								</tbody>
							</table>
							<s:if test="orderVOList != null && orderVOList.size > 0">
								<jsp:include page="../gadget/include_pagination.jsp"></jsp:include>
							</s:if>
						</div>
						
					</div>
				</div>
			</div>
		</div>
			
	<jsp:include page="../gadget/include_script.jsp"></jsp:include>
	<script type="text/javascript">
		$(document).ready(function () {
			$('#sidebar_order').addClass('open');
			$('#sidebar_order').addClass('active');
			$('#sidebar_order_manager').addClass('active');
		});
		jQuery(function($) {
			
			$('table th input:checkbox').on('click' , function(){
				var that = this;
				$(this).closest('table').find('tr > td:first-child input:checkbox')
				.each(function(){
					this.checked = that.checked;
					$(this).closest('tr').toggleClass('selected');
				});
					
			});
		
		});
		
		function preupdateorder(orderId) {
			$('#csc_order_update_orderId').attr('value', orderId);
			$('#csc_order_preUpdate_form').submit();
		}
		
		function deleteOrder() {
			var selectedIds = '';
			$('#order_list_table').find('tr > td:first-child input:checkbox').each(function(){
				if(this.checked == true || this.checked == 'checked') {
					if(selectedIds != '') {
						selectedIds += ' ';
					}
					selectedIds += $(this).attr('lang');
				}
			});
			if($.trim(selectedIds) == '') {
				alert('请选择待删除的条目！');
				return ;
			}
			$('#csc_order_deletedOrderIds').attr('value', selectedIds);
			$('#csc_order_delete_form').submit();
		}
		
		function showOrderDetail(orderId) {
			$('#csc_order_detail_orderId').attr('value', orderId);
			$('#csc_order_detail_form').submit();
		}
		
		function gotoPage(currentPage) {
			$('#csc_order_search_currentPage').attr('value', currentPage);
			$('#csc_order_search_form').submit();
		}
	</script>
	</body>
</html>